import { ConfigEnv, defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }: ConfigEnv) => {
  return {
    base: mode === 'production' ? '/admin' : '/',
    plugins: [vue()],
    resolve: {
      alias: {
        '@': resolve(__dirname, 'src'),
        '#': resolve(__dirname, 'types'),
      },
    },
    build: {
      target: 'es2015',
      // 项目打包输出地址
      outDir: '../server/dist/apps/client-admin',
      terserOptions: {
        compress: {
          keep_infinity: true,
        },
      },
      brotliSize: false,
      chunkSizeWarningLimit: 1500,
    },
    optimizeDeps: {
      include: ['element-plus/lib/locale/lang/zh-cn'],
    },
  }
})
